unit fonction;

{$R-,T-,H+,X+}

interface                         
        uses SysUtils, Classes;

        type VAR_CLOSURE = procedure( bAFaire: Boolean) of object;

        function SetFonction( obj : TObject; ProcName:String) : VAR_CLOSURE;
        function SetFonction2( obj : TObject; ProcAddress:Pointer) : VAR_CLOSURE;


implementation
    function SetFonction( obj : TObject; ProcName:String) : VAR_CLOSURE;
    begin
        Result := SetFonction2(obj, obj.MethodAddress( ProcName));
    end;
    function SetFonction2( obj : TObject; ProcAddress:Pointer) : VAR_CLOSURE;
    begin
        TMethod(Result).Code := ProcAddress;
        TMethod(Result).Data := obj;
    end;

end.



